Repository navigation
Add per-display HDR and rotation to the Display panel - #7340
AllStars101-sudo wants to merge 8 commits into
Conversation
Anything the Display panel sets has to survive a reload, which means editing the user's monitors.lua. Doing that with sed is what produced omacom#6673: the scale writer matches the catch-all rule, so one display's choice lands on every display. This parses the Lua instead. It identifies comments and long-bracket strings in one pass and makes every structural decision against that mask, so a commented-out hl.monitor example is never mistaken for a live rule -- which matters because the stock monitors.lua ships full of them. Rules are matched by output name or by the desc: string the user wrote, the catch-all is never touched, and formatting and comments survive a write.
hyprctl says what a display is currently doing, not what it can do, so a panel has no way to tell whether an HDR switch would work before offering it. A display's EDID carries an HDR Static Metadata Data Block, and one advertising the PQ transfer function (SMPTE ST2084) means HDR. The same block carries the mastering luminances Hyprland wants, so a single read both gates the control and supplies sensible values for it.
Changing how much room a display occupies leaves every other display where it was, so displays pinned to explicit positions collide -- which is what Hyprland's "Your monitor layout is set up incorrectly" warning means. Only overlaps are resolved. A gap is not an error, Hyprland never complains about one, and re-packing a valid layout would move displays the user placed on purpose. Mirrored displays are skipped, since they share a position by definition and would otherwise read as a total overlap. Callers pass --intended to describe the layout a change is about to produce, so neighbours can be moved before the change lands rather than after: the warning fires on the overlapping instant and stays up once the layout is valid again.
Turning HDR on takes the mastering luminances from the display's own EDID rather than asking anyone to guess them, and leaves luminances already tuned by hand in monitors.lua alone. Turning it off keeps those luminances, since they are inert under sRGB and should still be there on the way back. --sdr-brightness sets where SDR white sits inside the HDR volume. That is not the backlight, and the two are complementary rather than alternatives, so the help text says which is which.
Hyprland's transform is an integer 0-7 rather than an angle: 0-3 are the plain rotations and 4-7 repeat them mirrored. This speaks degrees and keeps the mirrored half behind --flipped, so rotating a mirrored display does not silently unmirror it. A quarter turn swaps how much room the display takes up, so neighbours are moved clear of its real post-rotation footprint before it turns.
transform, colour management preset and SDR luminance all come free from the hyprctl payload monitor state already reads.
Rotation is a row of chips below Scale. HDR is a switch on the hero's trailing edge, where the Bluetooth panel keeps its power switch, and appears only when the focused display's EDID advertises it. Both sit in the panel's existing single column, and putting HDR in the hero rather than giving it a row is what keeps the panel fitting without scrolling. While HDR is on, the Brightness slider drives SDR white inside the HDR volume instead of the backlight. Displays generally lock their own brightness to the HDR tone curve in HDR, but still acknowledge a DDC/CI write and report the new value back, so nothing here can detect that the slider did nothing. The brightness keys still drive the backlight. HDR capability is a slower EDID read than the rest of the panel's state, so it is fetched only when the focused display changes rather than on the poll.
Also covers what Hyprland's monitor layout warning means and how to settle an overlapping layout by hand.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
+1 for this, a per-display HDR switch in the Display panel is the missing piece in 4.5.0 for me. Right now the panel offers brightness, text size and scale, but HDR has to be configured by hand in My setup, in case it helps with testing: Omarchy 4.5.0-3, Hyprland 0.56.2, AMD Radeon RX 6500 XT on Wayland. Happy to test a rebased version of this PR. Is there anything blocking it besides the merge conflicts with main? |
|
@AllStars101-sudo, thanks for this PR, it is exactly what the Display panel is missing. It currently shows merge conflicts with main. Do you plan to rebase it, and is there anything you would like from others to move it forward (testing on other hardware, splitting it into smaller PRs for easier review, feedback on the brightness-slider-under-HDR question from the discussion)? I run Omarchy 4.5.0-3 on AMD (RX 6500 XT) and can test a rebased version. |
What this adds
Rotation and HDR controls in the Display panel, both scoped to a single display, plus the commands behind them.
Rotation is a row of chips (
0° / 90° / 180° / 270°) below Scale. HDR is a switch on the hero's trailing edge, where the Bluetooth panel keeps its power switch, and appears only when the focused display's EDID advertises HDR, so displays that can't do it aren't offered a switch that would fail. Turning HDR on uses the mastering luminances from that display's own EDID; luminances already tuned by hand inmonitors.luaare kept rather than overwritten.Both sit in the panel's existing single column rather than behind any new navigation, and the panel still fits without scrolling: putting HDR in the hero rather than giving it a row of its own is what buys the space.
Screenshots
An HDR display (DP-1, a 4K QD-OLED). The HDR switch sits on the hero, and Brightness is driving SDR white inside the HDR volume rather than the backlight, which is what the caption underneath says.
A non-HDR display, rotated (DP-3, a 4K panel at 90°). Same panel, same moment, different focused display: Scale and Rotation relabel to DP-3, 90° is the active rotation, Brightness reads that display's own backlight, and the HDR switch is absent because its EDID advertises no PQ transfer function.
Brightness under HDR
Displays generally lock their own brightness to the HDR tone curve while in HDR. Critically, they still acknowledge a DDC/CI write and report the new value back, so nothing in the panel can detect that the change had no effect — the slider moves and the picture doesn't.
So while HDR is on, the Brightness slider drives
sdr_max_luminance: where SDR white sits inside the HDR volume, and the knob that actually changes how bright the desktop looks. It stays a percentage of what the display can hold, so the control reads the same either way, with an "Adjusts SDR brightness" caption naming which knob it is on. The brightness keys still drive the backlight.Its range tops out at the display's sustained full-field luminance rather than its peak: peak applies to small highlights, and mapping SDR white there makes a full white window dim as the panel's brightness limiter pulls power back.
Persistence
Anything set here has to survive a reload, which means editing the user's
monitors.lua. Doing that withsedis what produced #6673 — the scale writer matches the catch-all rule, so one display's choice lands on every display.omarchy-hyprland-monitor-ruleparses the Lua instead. It identifies comments and long-bracket strings in one pass and makes every structural decision against that mask, so:hl.monitorexample is never mistaken for a live rule — which matters because the stockmonitors.luaships full of them, and matching one would write into the documentation while the real display keeps its old value--[[ ]]block comments and[[ ]]long strings can't throw off brace or quote trackingvrr = 0, -- whycomment isn't swallowed on the next writeOn top of that it matches a rule by output name or by the
desc:string the user wrote, keeping whichever identifier they chose; never matches the catch-all (output = ""); preserves CRLF endings and writes through a symlinkedmonitors.luarather than replacing it with a regular file; and seeds a new rule from live geometry, because a rule that omitspositiondoes not inherit the catch-all's and would otherwise move the display to 0x0.It's a general per-display writer, so it would also serve #6710's scale fix.
Keeping the layout valid
A quarter turn changes how much room a display occupies while every display keeps the position it had, so displays pinned to explicit positions collide. Repairing that afterwards is not enough:
CMonitorLayoutController::checkOverlapsAndNotifyfires the moment two displays overlap, and the notification stays up once the layout is valid again. So rotation moves the neighbours clear of the display's real post-rotation footprint before it turns, and no overlapping layout ever exists.omarchy-hyprland-monitor-tidydoes that work and is also available on its own, for a layout that ends up overlapping some other way. It resolves overlaps only, moving displays along the axis they were already arranged on. A gap is left alone — Hyprland never complains about gaps, and re-packing a valid layout would move displays the user placed on purpose. An earlier version that closed gaps dragged a whole row sideways when one tall display spanned two of them.Mirrored displays are excluded, since they share a position by definition and would otherwise read as a 100% overlap and get un-mirrored.
Positions are persisted before the config write that triggers Hyprland's reload, so the reload cannot restore the old ones underneath the new geometry. And
hyprctlreports a display's mode rather than its rotated result, so a quarter turn has to swap the axes before any of this arithmetic is right.Scale changes are deliberately left alone.
omarchy-hyprland-monitor-scalinghas always resized without repositioning, so it hits the same overlap warning, and it was tempting to fix here. But Omarchy stores scale as a single global catch-all while positions are per display, and wiring the two together meant a display moved by tidy picked up a per-display rule pinning its current scale — which then outranked the catch-all and silently reverted every later scale change for that display. That is #6710's territory, and this PR stays out of it.omarchy hyprland monitor tidycleans up after a scale change by hand.New commands
omarchy-monitor-statealso reportstransform,hdr, andsdrMaxLuminance, which come free from thehyprctlpayload it already reads. HDR capability is a slower EDID read, so the panel fetches it separately and only when the focused display changes — not on the 5s poll.Relationship to the other open PRs
This is additive and aimed at the gap the others leave:
sed.Panel.qml.eval) — no overlap.Happy to rebase on whichever lands first.
Test plan
Six suites under
test/shell.d/, written against the commands' observable behaviour rather than their internals — each drives a real temporarymonitors.luaand a stubbedhyprctl, so they'd still pass if the implementations were rewritten.monitor-rule-test.sh— the Lua writer:desc:matching, catch-all isolation, commented-out rules left alone,--[[ ]]and[[ ]]tokenization, comment and CRLF preservation, symlink write-through, seeding, backup pruning, clean failure. Output is checked withluacwhere available.monitor-tidy-test.sh— the layout arithmetic: overlap measurement, the quarter-turn axis swap, stacked arrangements staying stacked, the anchor not moving, gaps left alone, mirrored and disabled displays ignored, and planning for a pending change.monitor-hdr-test.sh— capability gating and--force, tuned luminances preserved, luminances kept acrossoff, SDR brightness validation, status shape.monitor-rotate-test.sh— degree and alias parsing, the mirrored half preserved across a rotation,--no-flipped,--no-tidy, argument errors.monitor-test.sh— the panel model: rotation mapping, SDR range and clamping, percentage round-trips, capability parsing.monitor-state-test.sh— the new fields../test/cliNote for reviewers
HDR brightness can't be verified from a screenshot —
grimcaptures before tone mapping, so a 250→500 nit sweep moves the captured image mean by about one level. Evidence here ishyprctl monitorsstate and the EDID read, not before/after images.Known limitations
Under HDR the Brightness slider is remapped, not removed. This is a deliberate design decision rather than a lost capability. The backlight remains fully controllable — the brightness keys and
omarchy brightness displaydrive it exactly as before, on every display, in HDR or out of it. What changes is only which knob the panel's slider is wired to. The panel cannot tell whether a given display honours a backlight change in HDR, because displays acknowledge the DDC/CI write and report the new value back either way, so the slider would silently do nothing on most hardware if left as it was. Pointing it atsdr_max_luminancemeans it always moves something the user can see. On the displays that do honour the backlight in HDR, that adjustment lives on the brightness keys instead of the slider.Tidying resolves overlaps; it does not arrange. It moves displays along the axis they were already on and won't rearrange a layout for you, and it assumes one row or one column. Add drag-to-arrange monitor layout in Display #7152's drag-to-arrange canvas is the right home for real arrangement, and this composes with it rather than competing.
Scale changes still don't reposition. Unchanged from today's behaviour, and explained above — the fix belongs with whoever makes scale per-display.
omarchy hyprland monitor tidyis the manual remedy in the meantime.cleanScaleis only exact on the offered presets. Rounding an arbitrary scale to the nearest one Hyprland accepts isn't idempotent for every input in 1×–4×, though all six presets the panel offers are fixed points. Tightening it means changingnormalizeScale's 2-decimal rounding, whichmatchingScaleIndexcompares against — worth doing separately rather than inside this change.--forceexists for enabling HDR on a display whose EDID doesn't advertise it — some displays lie or report nothing over certain adapters.